package com.lightsaber.trade.core.entity.account;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.lightsaber.trade.core.common.constants.AppConstant;
import com.lightsaber.trade.core.entity.BaseEntity;

/**
 * 权限.
 * 
 * 注释见{@link User}.
 * 
 * @author LiuJian
 */
@Entity
@Table(name = "ACCT_AUTHORITY")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Authority extends BaseEntity {

    private static final long serialVersionUID = 3170848076206345922L;

    @Column(nullable = false, unique = true)
    private String name;

    @Column(length = 255)
    private String interceptUrl;

    public Authority() {
    }

    public Authority(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getInterceptUrl() {
        return interceptUrl;
    }

    public void setInterceptUrl(String interceptUrl) {
        this.interceptUrl = interceptUrl;
    }

    @Transient
    public String getPrefixedName() {
        return AppConstant.AUTHORITY_PREFIX + name;
    }

}
